//
//  ViewController.m
//  考试
//
//  Created by 罗鑫伟 on 2016/12/16.
//  Copyright © 2016年 罗鑫伟. All rights reserved.
//

#import "ViewController.h"
#define ScreenWidte [UIScreen  mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#import "TableViewController.h"
@interface ViewController ()<UIScrollViewDelegate>
@property(nonatomic,retain)UIScrollView *scroll;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //self.view.backgroundColor=[UIColor redColor];
    self.title=@"相册";
    _scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidte, ScreenHeight-64)];
    self.scroll.contentSize=CGSizeMake(ScreenWidte, 330*3);
    [self.view addSubview:_scroll];
    for (NSInteger i = 1; i <= 6; i++) {
        UIImageView *imageView = [[UIImageView alloc] init];
        if (i % 2 != 0) {
            imageView.frame = CGRectMake(0,330 * (i / 2) , ScreenWidte / 2.0, 330);

        }
        else
        {
            imageView.frame = CGRectMake(ScreenWidte / 2.0, 330 * ((i - 1) / 2), ScreenWidte / 2.0, 330);
        }
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld.jpg", i]];
        
        imageView.tag = 1000 + i;
        
        imageView.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapImageView:)];
        
        [imageView addGestureRecognizer:tapGesture];
        
        [self.scroll addSubview:imageView];
        
        
    }
}
    
- (void)didTapImageView:(UITapGestureRecognizer *)tap
{

    NSInteger number = tap.view.tag - 1000;
    NSLog(@"%ld", number);
    
    TableViewController *dVC = [[TableViewController alloc] init];
  
    dVC.num = number;
    [self.navigationController pushViewController:dVC animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
